﻿using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;
using com.IronOne.BoardPACWinApp.Common;
using com.IronOne.BoardPACWinApp.Helpers;
using com.IronOne.BoardPACWinAppService.Auth;

// The User Control item template is documented at http://go.microsoft.com/fwlink/?LinkId=234236

namespace com.IronOne.BoardPACWinApp.View.UserControl
{
    public sealed partial class MenuTopAppBarUserControl
    {
        private AppBar _bottom;
        private AppBar _top;
        private readonly IAuthService _authService;
        private readonly IDialogService _dialogService;
        private readonly INavigationService _navigationService;

        public MenuTopAppBarUserControl()
        {
            InitializeComponent();
            _navigationService = new NavigationService();
            _dialogService = new DialogService();
            _authService = new AuthService();
        }

        /*private void SettingsButton_Click(object sender, RoutedEventArgs e)
        {
            BasePage.SettingsButton_Click(_navigationService);
        }*/

        private async void LogoutButton_Click(object sender, RoutedEventArgs e)
        {
            var frame = (Frame) Window.Current.Content;
            var page = frame.Content as LayoutAwarePage;

            _top = page.TopAppBar;
            _bottom = page.BottomAppBar;

            page.TopAppBar = null;
            page.BottomAppBar = null;

            await BasePage.LogoutButton_Click(_navigationService, _dialogService, _authService);

            page.TopAppBar = _top;
            page.BottomAppBar = _bottom;
        }
    }
}